package xman.mssh.hibernate;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import xman.mssh.hibernate.entity.JpaEntity;

public class Jpa {
    
    static Logger logger = LoggerFactory.getLogger(Jpa.class);

    @Test
    public void def() {
        // access default persistence.xml (META-INF/persistence.xml)
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("default");
        EntityManager em = factory.createEntityManager();
        em.getTransaction().begin();
        JpaEntity entity = new JpaEntity();
        entity.setDescr("jpa");
        em.merge(entity);
        em.getTransaction().commit();
        em.close();
        factory.close();
        logger.info("@def jpa finish");
    }
    
}
